<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>后台登录</title>
    <link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="/static/admin/css/login.css"/>
</head>

<body>
    <!--侧边栏-->
    <div class="main-layout-side">
    <div class="m-logo">
    </div>
    <ul class="layui-nav layui-nav-tree" lay-filter="leftNav">
    </ul>
</div>
<script src="/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery','element'],function (){
        var $= layui.jquery;
        var element = layui.element();
        $.ajax({
            type:"GET",
            url : "/admin/Tree/Menu",
            dataType:"json",
            success : function(res){
                for (var re of res.data) {
                    var content='<li class="layui-nav-item">';
                    content +=  '   <a href="javascript:;"><i class="iconfont">'+re.icon+'</i>'+re.menuname+'</a>';
                    if (re.childrens!=null){
                        content +=' <dl class="layui-nav-child">';
                        for(var c of re.childrens) {
                            content += '<dd>';
                            content += ' <a href="javascript:;" data-url=' + c.curl + ' data-id="3" data-text=' + c.cname + '><span class="l-line"></span>' + c.cname + '</a>'
                            content += '</dd>';
                        }
                        content += '</dl>'
                    }
                    content +=   '</li>';
                    $(".layui-nav-tree").append(content);
                    element.init();
                }
            }

        })
    })
</script>
</body>
</html>
